package com.sniper.web.listener;

import com.sniper.web.utils.QuartzManagerUtil;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 挡系统关闭的时候做一些事
 *
 * @author suzhen
 */
@Component
public class InitStopOnBoot implements ApplicationListener<ContextStoppedEvent> {


    @Resource
    QuartzManagerUtil quartzManagerUtil;

    @Override
    public void onApplicationEvent(ContextStoppedEvent event) {
        try {
            System.out.println("停止任务调度器");
            quartzManagerUtil.stop();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }

}
